package com.demo.hotel_book.controller;


import com.demo.hotel_book.config.AlipayConfig;
import com.demo.hotel_book.mapper.OrderZoneMapper;
import com.demo.hotel_book.util.AlipayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AlipayController {

    @Autowired
    OrderZoneMapper orderZoneMapper;

    @Autowired
    AlipayConfig alipayConfig;
    @Autowired
    AlipayUtil alipay;
    /**
     * 调用支付宝接口
     */
    @RequestMapping(value = "/goAlipay", produces = "text/html; charset=UTF-8")
    @ResponseBody
    public String goAlipay(String orderId,String price) throws Exception {
        return alipay.goAlipay(orderId,price);
    }

    @RequestMapping("return_url")
    public String returnUrl(String out_trade_no) {
        orderZoneMapper.updateOrder(out_trade_no);
        return "redirect:/contact";
    }

}
